package org.micode.demo.db.dao;

import org.micode.demo.db.domain.dto.SysRoleMenuDTO;
import org.micode.libs.dao.base.BaseAllDao;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 角色资源权限(sys_role_menu) 实体类的Dao
 *
 * author: wutianbin
 */
@Mapper
public interface SysRoleMenuDao extends BaseAllDao<SysRoleMenuDTO> {

    // 非常规sql写这里--- xml 自动生成,不再手动在xml中写sql !!
    @Select("SELECT menu_id FROM sys_role_menu " +
            " WHERE role_id = #{roleId}")
    @ResultType(Long.class)
    List<Long> listMenuIdByRoleId(@Param("roleId") Long roleId);

    @Delete("delete from sys_role_menu " +
            "  where role_id=#{roleId}")
    void deleteForRoleId(@Param("roleId") Long roleId);

    @Delete("delete from sys_role_menu " +
            "  where menu_id=#{menuId}")
    void deleteForMenuId(@Param("menuId") Long menuId);

}
